<extend name="Index:base" />
<block name="stylecss">
	<link rel="stylesheet" href="__PUBLIC__/admin/css/datepicker.css" />
</block>
<block name="content">
	<div class="main-content">
		<div class="breadcrumbs" id="breadcrumbs">
			<!-- 面包屑导航 -->
			<ul class="breadcrumb">
				<li>
					<i class="icon-home home-icon"></i>
					<a href="{:U('Admin/Index/index')}">首页</a>
				</li>
				<li>
					<a href="{:U('Admin/Indexset/index')}">{$page['title']['prev']}</a>
				</li>
				<li class="active">
					{$page['title']['current']}
				</li>
			</ul>
		</div>

		<div class="page-content">

			<!-- 页面导航 -->
			<div class="page-header">
				<h1>
					{$page['title']['current']}
					<a class="btn btn-info btn-sm pull-right" href="{:U('Admin/Indexset/index')}">
						<i class="icon-reply icon-only"></i>
					</a>
				</h1>
			</div>

			<div class="row" style="margin-top:35px;">
				<div class="col-xs-12">
					<form class="form-horizontal" role="form" action="{:U('Admin/Indexset/editAd')}" method="post" enctype="multipart/form-data">
                        <input type="hidden" name="fadid" value="{$Think.get.id}">
                        <input type="hidden" name="adtype" value="pic">
                        <div class="form-group">
							<label class="col-sm-2 control-label no-padding-right"> 投放位置 </label>
                            <div class="col-sm-10">
                                <div class="col-xs-10 col-sm-5  no-padding">
                                    <select class="form-control" name="fadplace">
                                        <option value="1" {$adinfo['fadplace']==1?"selected":""}>左侧幻灯片</option>
                                        <option value="2" {$adinfo['fadplace']==2?"selected":""}>中间推荐位</option>
                                        <option value="3" {$adinfo['fadplace']==3?"selected":""}>右侧广告</option>
                                    </select>
                                </div>
                            </div>
						</div>
						<div class="form-group">
							<label class="col-sm-2 control-label no-padding-right"> 广告标题 </label>
							<div class="col-sm-10">
								<input class="col-xs-10 col-sm-5" type="text" value="{$adinfo['fadtitle']}" name="fadtitle">
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-2 control-label no-padding-right"> 广告URL </label>
							<div class="col-sm-10">
								<input class="col-xs-10 col-sm-5" type="url" value="{$adinfo['fadurl']}" name="fadurl">
							</div>
						</div>
						<div class="form-group" style="margin-bottom:0px;">
							<label class="col-sm-2 control-label no-padding-right"> 上传广告图片 </label>
							<div class="col-sm-10">
								<div class="ace-file-input no-padding col-xs-10 col-sm-5">
									<input style="height:30px;" type="file" id="id-input-file-2" name="fadpic" />
                                </div>
                                <img class="full-right" style="margin-left:10px;" src="__PUBLIC__/Uploads/{$adinfo['fadpic']|explode='/',###|implode='/th_',###}" height="30">
							</div>
						</div>
                        
						<div class="form-group" >
							<label class="col-sm-2 control-label no-padding-right"> 广告生效日期 </label>
							<div class="col-sm-10">
								<div class="col-xs-10 col-sm-5 no-padding" >
									<div class="input-group">
										<span class="input-group-addon">
											<i class="icon-calendar bigger-90"></i>
										</span>
										<input style="height:30px;" class="form-control date-picker" id="id-date-picker-1" type="text" data-date-format="yyyy-mm-dd" name="fadstarttime" value="{$adinfo['fadstarttime']>0?$adinfo['fadstarttime']|date='Y-m-d',###:''}">
									</div>
								</div>
							</div>
						</div>
						<div class="form-group" >
							<label class="col-sm-2 control-label no-padding-right"> 广告失效日期 </label>
							<div class="col-sm-10">
								<div class="col-xs-10 col-sm-5 no-padding" >
									<div class="input-group">
										<span class="input-group-addon">
											<i class="icon-calendar bigger-90"></i>
										</span>
										<input style="height:30px;" class="form-control date-picker" id="id-date-picker-2" type="text" data-date-format="yyyy-mm-dd" name="fadendtime" value="{$adinfo['fadendtime']>0?$adinfo['fadendtime']|date='Y-m-d',###:''}">
									</div>
								</div>
							</div>
						</div>
						<div class="clearfix form-actions">
							<div class="col-md-offset-2 col-md-10">
								<button class="btn btn-info" type="submit">
									<i class="icon-ok bigger-110"></i>
									提交
								</button>

								&nbsp; &nbsp; &nbsp;
								<button class="btn" type="reset">
									<i class="icon-undo bigger-110"></i>
									重置
								</button>
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
</block>
<block name="privatejs">
	<script src="__PUBLIC__/admin/js/date-time/bootstrap-datepicker.min.js"></script>
	<script type="text/javascript">
		jQuery(function($) {

			//设置当前页面的菜单高亮显示 开始
			var nownav = '#sidebar a[href*=Indexset]';
			var parentattr = $(nownav).parent().parent().attr("class");
			$(nownav).parent().addClass('active');
			if (parentattr == 'submenu') {
				$(nownav).parent().parent().parent().addClass('active open');
			};
			//设置当前页面的菜单高亮显示 结束

			$('#id-input-file-2').ace_file_input({
				no_file:'选择广告图片 ...',
				btn_choose:'上传',
				btn_change:'修改',
				droppable:false,
				onchange:null,
				thumbnail:false //| true | large
				//whitelist:'gif|png|jpg|jpeg'
				//blacklist:'exe|php'
				//onchange:''
				//
			});	
		
			//文件上传
			$('#id-file-format').removeAttr('checked').on('change', function() {
				var before_change
				var btn_choose
				var no_icon
				if(this.checked) {
					btn_choose = "Drop images here or click to choose";
					no_icon = "icon-picture";
					before_change = function(files, dropped) {
						var allowed_files = [];
						for(var i = 0 ; i < files.length; i++) {
							var file = files[i];
							if(typeof file === "string") {
								//IE8 and browsers that don't support File Object
								if(! (/\.(jpe?g|png|gif|bmp)$/i).test(file) ) return false;
							}
							else {
								var type = $.trim(file.type);
								if( ( type.length > 0 && ! (/^image\/(jpe?g|png|gif|bmp)$/i).test(type) )
										|| ( type.length == 0 && ! (/\.(jpe?g|png|gif|bmp)$/i).test(file.name) )//for android's default browser which gives an empty string for file.type
									) continue;//not an image so don't keep this file
							}
							
							allowed_files.push(file);
						}
						if(allowed_files.length == 0) return false;
		
						return allowed_files;
					}
				}
				else {
					btn_choose = "Drop files here or click to choose";
					no_icon = "icon-cloud-upload";
					before_change = function(files, dropped) {
						return files;
					}
				}
				var file_input = $('#id-input-file-3');
				file_input.ace_file_input('update_settings', {'before_change':before_change, 'btn_choose': btn_choose, 'no_icon':no_icon})
				file_input.ace_file_input('reset_input');
			});

			$('.date-picker').datepicker({autoclose:true}).prev().on(ace.click_event, function(){
				$(this).next().focus();
			});

		});
	</script>
</block>